package com.liuceng.lib.gdt.utils

import com.liuceng.peatio.utils.CoeUtils
import spock.lang.Specification
import spock.lang.Unroll

import static spock.util.matcher.HamcrestMatchers.closeTo

/**
 * Created by liyuhang on 2016-27-4.
 */
@Unroll
class CoeUtilsSpec extends Specification {

    def "应该可以根据 客单,区间,系数 正常的获取系数"() {
        expect:
        def c = CoeUtils.getMajorCof(cost, marks, values)
        c closeTo(coe, 0.01)

        where:
        cost  | marks                                     | values                                                                                                                || coe
        0.0   | "50,100,150"                              | "2,3,3,2.5,2.5,1.3,1.3,1.2"                                                                                           || 2.0
        0.0   | "50"                                      | "6,2,3,4.5"                                                                                                           || 6.0
        12    | "50"                                      | "10,5,4,3.2"                                                                                                          || 5
        76.38 | "5,6,7,8,9,10,12,15,18,20,25,30,35,40,50" | "1,10,10,8.2,8.2,7.5,7.5,6.5,6.5,6.2,6.2,5.5,5.5,4.5,4.5,3.9,3.9,3.3,3.3,3,3,2.5,2.5,2,2,1.7,1.7,1.7,1.7,1.4,1.4,1.1" || 1.1
        36    | "5,6,7,8,9,10,12,15,18,20,25,30,35,40,50" | "1,10,10,8.2,8.2,7.5,7.5,6.5,6.5,6.2,6.2,5.5,5.5,4.5,4.5,3.9,3.9,3.3,3.3,3,3,2.5,2.5,2,2,1.7,1.7,1.7,1.7,1.4,1.4,1.1" || 1.7
        25    | ""                                        | "1,5"                                                                                                                 || 5
    }

}